@extends('Admin.layouts.application')
@section('content')
  <div class="admin-content">
  <div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
      <div class="am-fl am-cf">
        <strong class="am-text-primary am-text-lg">修改菜单</strong> /
        <small>Modify menu</small>
      </div>
    </div>

    <hr>
    @include('Admin.layouts._flash')
    <form class="am-form" method="post" action="{{route('category.update',$category->id)}}">
      {!! method_field('put') !!}
      {!! csrf_field() !!}

        <div class="am-g am-margin-top">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                菜单
            </div>
            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                <select data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 360}"
                        name="parent_id">
                    @if($data['data']==true)
                        <option value="0">一级分类</option>
                        @foreach ($categories as $c)
                            @if($c->id == $category->id || $c->parent_id==0)
                                 continue;
                            @else
                                <option value="{{ $c->id }}" @if($c->id == $category->parent_id) selected @endif>
                                    {{ $c->name }}
                                </option>
                            @endif
                        @endforeach
                     @else
                        @foreach ($categories as $c)
                            <option value="{{ $c->id }}" @if($c->id == $category->parent_id) selected @endif>
                                {{ $c->name }}
                            </option>
                        @endforeach
                    @endif
                </select>
            </div>
        </div>

        <div class="am-g am-margin-top">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                修改菜单
            </div>
            <div class="am-u-sm-8 am-u-md-4">
                <input type="text" class="am-input-sm" name="name" value="{{$category->name}}">
            </div>
            <div class="am-hide-sm-only am-u-md-6">*必填，不可重复</div>
        </div>




        <div class="am-g am-margin-top sort">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                排序
            </div>
            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                <input type="text" name="sort_order" class="am-input-sm" value="{{$category->sort_order}}">
            </div>
        </div>
        @if($category->parent_id != 0)
        <div class="am-g am-margin-top">
            <div class="am-u-sm-4 am-u-md-2 am-text-right">
                是否显示
            </div>
            <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                <label class="am-radio-inline">
                    <input type="radio" value="1" name="is_show" @if($category->is_show == 1) checked @endif> 是
                </label>
                <label class="am-radio-inline">
                    <input type="radio" value="0" name="is_show" @if($category->is_show == 0) checked @endif> 否
                </label>
            </div>
        </div>
        @endif

    <div class="am-margin">
      <button type="submit" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
      <a href="javascript:history.go(-1);" class="am-btn am-btn-primary am-btn-xs">放弃保存</a>
    </div>
    </form>
  </div>

      @include('Admin.layouts._footer')
</div>
@endsection

@section('js')
    <script src="/assets/xSystem/js/jquery.html5-fileupload.js"></script>
    <script src="/assets/xSystem/js/upload.js"></script>
    <script src="/assets/xSystem/vendor/ckfinder/ckfinder.js"></script>
    <script src="/assets/xSystem/js/ck_upload.js"></script>
@endsection
